Programming Assignments 编程作业
PA 1
Problem Sheet: hw1.pdf
Examplar Program: hw1_example.cpp
TA comments:
-- At the stage of hw1, the neat implementation of a linked list is encouraged.
-- Some students naively copy codes from slide with redundant functionality. That is not elegant.
-- Many of you apply recursive function to solve it rapidly. That is good but it is far beyond the scope of linked list. So those submissions are not considered as a recommendation.
-- The anonymous request is allowed if that student hopes.
Student comments:
Recall the game rule: m people at first. Each time the (n-)th person after the present person is removed until 1 person left.
1. Construct a circular linked list with two ptrs pointing 1&n (2 ptrs helps to construct and delete, because there is never nullptr )
2. In main(), use while loop to delete the k-th next node until the size of circle is 1.(here k = (n-1)%m to get the distance from the current node )